<!--
 * @company : 版权所属 四川北星惯牌科技有限公司
 * @contact : 刘经理 19326416371
 -->
<template>
	<up-tabbar :value="tabIndex" :zIndex="9999999" :inactiveColor="tabBar.color" :activeColor="tabBar.selectedColor"
		@change="changTab" :fixed="true" :placeholder="true" :safeAreaInsetBottom="true">
		<up-tabbar-item text="首页">
			<template #active-icon>
				<image class="u-page__item__slot-icon" src="/static/tabBar/main_in.png">
				</image>
			</template>
			<template #inactive-icon>
				<image class="u-page__item__slot-icon" src="/static/tabBar/main.png"></image>
			</template>
		</up-tabbar-item>
		<up-tabbar-item text="附近">
			<template #active-icon>
				<image class="u-page__item__slot-icon" src="/static/tabBar/nearby_in.png">
				</image>
			</template>
			<template #inactive-icon>
				<image class="u-page__item__slot-icon" src="/static/tabBar/nearby.png"></image>
			</template>
		</up-tabbar-item>
		<view class="custom_style" @click="toAddteam">
			<up-icon name="plus" color="#191C1F" size="56rpx"></up-icon>
		</view>
		<up-tabbar-item :text="assistantTitle">
			<template #active-icon>
				<image class="u-page__item__slot-icon" src="/static/tabBar/activity_in.png">
				</image>
			</template>
			<template #inactive-icon>
				<image class="u-page__item__slot-icon" src="/static/tabBar/activity.png"></image>
			</template>
		</up-tabbar-item>
		<up-tabbar-item text="我的">
			<template #active-icon>
				<image class="u-page__item__slot-icon" src="/static/tabBar/user_in.png">
				</image>
			</template>
			<template #inactive-icon>
				<image class="u-page__item__slot-icon" src="/static/tabBar/user.png"></image>
			</template>
		</up-tabbar-item>
	</up-tabbar>
</template>

<script setup>
	import {
		groupNotification
	} from '@/utils/groupNotification';
	import {
		assistantNotification
	} from '@/utils/assistantNotification.js'
	import {
		userInfoStore
	} from '@/stores/user';
	import {
		configInfoStore
	} from '@/stores/config.js';
	const {configInfo} = configInfoStore();
	const props = defineProps({
		current: {
			default: 0
		}
	});
	onLoad(() => {})
	const userStore = userInfoStore();
	const tabBar = {
		"custom": true,
		"backgroundColor": "#191C1F",
		"color": "#869198",
		"selectedColor": "#7BDEC8",
		"list": [{
				"pagePath": "/pages/main/main",
				"iconPath": "/static/tabBar/main.png",
				"selectedIconPath": "/static/tabBar/main_in.png",
				"text": "首页"

			},
			{
				"pagePath": "/pages/nearby/nearby",
				"iconPath": "/static/tabBar/nearby.png",
				"selectedIconPath": "/static/tabBar/nearby_in.png",
				"text": "附近"

			},
			{
				"pagePath": "/pages/activity/activity",
				"iconPath": "/static/tabBar/activity.png",
				"selectedIconPath": "/static/tabBar/activity_in.png",
				"text": "活动"

			},
			{
				"pagePath": "/pages/user/user",
				"iconPath": "/static/tabBar/user.png",
				"selectedIconPath": "/static/tabBar/user_in.png",
				"text": "我的"
			}
		]
	}
	const assistantTitle=ref(computed(()=>configInfo.assistant_title.value))
	const tabIndex = ref(computed(() => props.current));
	const userInfo = ref(computed(() => userStore.userInfo));
	onShow(() => {
		// #ifdef APP
		uni.hideTabBar();
		// #endif
	});
	const toAddteam = () => { //去添加组队
		let token = uni.getStorageSync('user_token');
		if (!token) {
			uni.$u.toast('请先登录');
			setTimeout(() => {
				uni.navigateTo({
					url: '/pages/login/login'
				})
			}, 800)
			return
		}
		if (userInfo.value.is_authentication != 1) {
			uni.$u.toast('请先进行实名认证');
			setTimeout(() => {
				uni.navigateTo({
					url: '/page_user/views/authentication'
				})
			}, 800);
			return;
		};
		// 可直接查看
		uni.navigateTo({
			url: '/page_user/views/initiateTeam'
		})
		return;
		if (userInfo.value.is_captain != 1) {
			uni.$u.toast('请先认证队长');
			setTimeout(() => {
				uni.navigateTo({
					url: '/page_user/views/captainIn'
				})
			}, 800);
			return;
		}
		uni.navigateTo({
			url: '/page_user/views/initiateTeam'
		})

	}
	const changTab = (name) => { //切换tabbar
		allNotification(['assistantClose', 'assistantRefund', 'newAssistant'], () => {}); //打开通知
		tabIndex.value = name;
		uni.switchTab({
			url: tabBar.list[name].pagePath
		})
	}
</script>

<style lang="scss" scoped>
	.u-page__item__slot-icon {
		width: 48rpx;
		height: 48rpx;
	}

	.u-page__item__slot-icon {
		width: 48rpx;
		height: 48rpx;
	}

	.custom_style {
		background-color: #7BDEC8;
		font-size: 80rpx;
		width: 120rpx;
		height: 120rpx;
		border-radius: 50%;
		display: flex;
		justify-content: center;
		align-items: center;
		transform: translateY(-40rpx);
		position: relative;
		z-index: 99999;
	}
</style>